﻿using Pb;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NNExit : MonoBehaviour {

    public GameObject BackBtn;
    public GameObject GameBtn;
    public UILabel tishiLable;
    private void Awake()
    {
        UIEventListener.Get(BackBtn).onClick = ButtonClick;
        UIEventListener.Get(GameBtn).onClick = ButtonClick;
        
    }
    public void Start()
    {
        if (EginUser.Instance.ControlScene == 2)
        {
            if (EginDN.Instance.roomStatus==ROOM_STATUS.Gaming) {
                tishiLable.text = "现在退出将由系统帮你打完，输了可不负责哦？";
            }
        }
        
    }
    void ButtonClick(GameObject button)
    {
        if (button.name == "BackBtn")
        {
            if (EginDN.Instance.createrUid == (int.Parse)(EginUser.Instance.Uid))
            {
                RoomDismissRequest lg = new Pb.RoomDismissRequest { RoomId = EginDN.Instance.roomId };
                SocketManager socketManager = SocketManager.Instance;
                socketManager.SendProtobuf1(lg, MsgId.RoomDismissRequest);
                Destroy(gameObject);
            }
            else {
                RoomLeaveRequest lg = new Pb.RoomLeaveRequest { RoomId = EginDN.Instance.roomId };
                SocketManager socketManager = SocketManager.Instance;
                socketManager.SendProtobuf1(lg, MsgId.RoomLeaveRequest);
                Destroy(gameObject);
            }
           
        }
        else if (button.name == "GameBtn")
        {
            Destroy(gameObject);
        }
        
    }

}
